package com.zy.web.demo.duoxiancheng.demo23;

import com.zy.web.demo.duoxiancheng.demo22.ThreadA22;

/**
 * @author <a href="mailto:zhouyong@cqyyt.com">zy</a>
 * @version 1.0
 * @date 2020/8/24 10:30
 * join与sleep的区别
 * join的时候，锁可以被释放
 * sleep的时候锁不会被释放
 */
public class ThreadA23 extends Thread{

    private ThreadB23 B;

    public ThreadA23(ThreadB23 threadB23){
        super();
        this.B = threadB23;
    }

    @Override
    public void run() {
        synchronized (B){
            try {
                B.start();
                B.join();
                while (true){

                }
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
